package com.yudean.esb.service.impl.erp;

import com.yudean.esb.service.ERPPutService;
import com.yudean.esb.service.ErpClientService;
import com.yudean.esb.service.handler.ReceiveErpDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jws.WebService;


@WebService(endpointInterface = "com.yudean.esb.service.ERPPutService", serviceName = "ERPPutServiceService",targetNamespace = "http://service.esb.yudean.com/")
@Service
@Scope("prototype")
public class ERPPutServiceImpl implements ERPPutService {
    private final static Logger log = LoggerFactory.getLogger(ERPPutServiceImpl.class);
    @Resource
    private ReceiveErpDataService receiveErpDataService;

    @Resource
    private ErpClientService erpClientService;

    @Override
    public String putErpData(String serviceID, String token, String transactionID, String pkg, String totalPackage, String rollback, String forceReplace, String data) {
        try {
            erpClientService.addErpClientLog(token);
        } catch (Exception e) {
            log.error("save ERP log of /services/erpput error:", e);
        }
        log.info("putErpData():request-{serviceID:{},token:{},transactionID:{},pkg:{},totalPackage:{},rollback:{},forceReplace:{}}",serviceID,token,transactionID,pkg,totalPackage,rollback,forceReplace);
        return receiveErpDataService.putErpData(serviceID, token, transactionID, pkg, totalPackage, rollback, forceReplace, data);
    }
}
